package com.victor.system.controller;


import com.victor.system.service.SysCityService;
import com.victor.common.core.domain.R;
import com.victor.common.response.system.CityResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 城市字典表 controller
 * </p>
 *
 * @author benetech
 * @since 2022年12月19日
 */
@Api(tags = "REST - 城市字典表")
@RestController
@RequestMapping("/sysCity")
public class SysCityController {
    @Autowired
    SysCityService cityService;

    @GetMapping("/getProvince")
    @ApiOperation("获取省")
    public R<List<CityResponse>> getProvince (@ApiParam("省编码") String provinceCode) {
        return R.ok(cityService.getProvinceDictionary(provinceCode));
    }

    @GetMapping("/getCity")
    @ApiOperation("获取市")
    public R<List<CityResponse>> getCity (@ApiParam("省编码") String provinceCode) {
        return R.ok(cityService.getCityDictionary(provinceCode));
    }

    @GetMapping("/getDistrict")
    @ApiOperation("获取县区")
    public R<List<CityResponse>> getDistrict (@ApiParam("市编码") String cityCode) {
        return R.ok(cityService.getDistrictDictionary(cityCode));
    }

    @GetMapping("/getTown")
    @ApiOperation("获取乡镇")
    public R<List<CityResponse>> getTown (@ApiParam("县区编码") String districtCode) {
        return R.ok(cityService.getTownDictionary(districtCode));
    }

    @GetMapping("/getVillage")
    @ApiOperation("获取村居委")
    public R<List<CityResponse>> getVillage (@ApiParam("乡镇编码") String townCode) {
        return R.ok(cityService.getVillageDictionary(townCode));
    }

}
